﻿Public Class VoucherPrintDocument
    '1、数据控制：数据源（list）
    '2、打印控制：页面设置、页数控制、单页打印、凭证背景打印、凭证信息打印、标题打印、分录打印、合计打印、人员信息打印

    '打印结束通知外部
    Public Delegate Sub EndPrintCallBack(ByVal sender As Object, ByVal e As PrintCallBackEventArgs)
    Private m_EndCallBack As EndPrintCallBack

    '打印数据源
    Private m_VoucherList As List(Of ClsTVoucher)

    '公司信息
    Private m_CompanyName As String

    '页面控制
    '页边距设置
    Private m_LeftMargin As Integer
    Private m_RightMargin As Integer
    Private m_TopMargin As Integer
    Private m_BottomMargin As Integer

    '页数
    Private _TotalPages As Integer
    Private _CurrentPage As Integer

    '凭证
    Private _TotalVouchers As Integer '凭证总数
    Private _CurrentVoucherIndex As Integer '当前打印凭证索引
    Private _IfMultiPageOfVoucher As Boolean '当前打印凭证是否为多页
    Private _RowsOfCurrentVoucher As Integer '当前打印凭证总共有几行分录
    Private _PagesOfCurrentVoucher As Integer '当前打印凭证需要几页
    Private _PrintingPageOfCurrentVoucher As Integer '当前正在打印的是当前凭证的第几页
    Private _RowsOfPrintingPageOfCurrentVoucher '当前正在打印的凭证页的分录数量
    Private _RowIndexOfCurrentVoucher As Integer '当前打印凭证的下一页的行数索引（如果是第一页，则是6）
    Private _LeftRowsOfCurrentVoucher As Integer '当前打印凭证的下一页还有几行分录(如果是第一页，则是 分录总数 - 6)

    '单页行数
    Private _RowsOfPage As Integer '每页行数


    Private _CurrentRowOfPage As Integer '当前打印页的当前行
    Private _RowsOfAllPages As Integer '所有打印页的总行数
    Private _CurrentRowOfAllPages As Integer '当前行在所有页中索引

    '每页的绘制点
    Private _CurrentPoint As Point


    '字体设置
    Private m_TitleFont As Font '= New Font("宋体", 24, FontStyle.Bold)
    Private m_HeaderFont As Font ' = New Font("宋体", 10, FontStyle.Bold)
    Private m_ItemFont As Font '= New Font("宋体", 9, FontStyle.Regular)
    Private m_TextFont As Font '= New Font("宋体", 9, FontStyle.Regular)

    '笔刷设置
    Private m_Brush As SolidBrush ' = New SolidBrush(Color.Black)
    Private m_Pen As Pen '= New Pen(New SolidBrush(Color.Black))

    '单页高度设置
    Private m_PageTitleHeight As Single ' 记账凭证 标题区高
    Private m_PageInfoHeight As Single '凭证主体信息区高（单位名称等）
    Private m_EntryHeaderHeight As Single '分录标题高
    Private m_ItemHeight As Single '分录行高
    Private m_PageFooterHeight As Single '底部信息区高

    '宽度设置
    Private m_ExpWidth As Single '摘要宽度
    Private m_AcctWidth As Single '科目编码宽度
    'Private m_AcctNameWidth as single '科目名称宽度
    Private m_CreditWidth As Single '借方宽度
    Private m_DebitWidth As Single '贷方宽度
    Private m_VoucherSignWidth As Single '记账符号区
    Private _VoucherGroupNumberWidth As Single '凭证字号区，即时计算靠右对齐
    Private _VoucherDateWidth As Single '凭证日期区，即时计算，居中对齐

    Private m_CompanyWidth As Single '单位名称宽度

    Private m_VoucherPageWidth As Single '凭证总体打印宽度
    Private m_RowWidth As Single '一行分录的总宽度

    Private m_VoucherFooterTextWidth As Single '底部信息区文字宽度：平均分配


    '凭证标题内容
    Private m_VoucherTitle As String
    Private m_ExpTitle As String
    Private m_AcctTitle As String
    Private m_CreditTtile As String
    Private m_DebitTitle As String
    Private m_SignTitle As String

    '分辨率设定
    Private _dpiX As Single = 96
    Private _dpiY As Single = 96

    Public Sub New()
        '初始化打印值
        '页边距设置
        m_LeftMargin = 10
        m_RightMargin = 10
        m_TopMargin = 20
        m_BottomMargin = 20

        '页数
        _TotalPages = 0
        _CurrentPage = 0
        _TotalVouchers = 0
        _CurrentVoucherIndex = 0
        _IfMultiPageOfVoucher = False

        '单页行数
        _RowsOfPage = 6
        _CurrentRowOfPage = 0
        _RowsOfAllPages = 0
        _CurrentRowOfAllPages = 0

        '凭证标题名称
        m_VoucherTitle = "记账凭证"
        m_ExpTitle = "摘        要"
        m_AcctTitle = "会 计 科 目"
        m_CreditTtile = "借    方"
        m_DebitTitle = "贷    方"
        m_SignTitle = "记账符号"

        '字体设置
        m_TitleFont = New Font("宋体", 18, FontStyle.Bold)
        m_HeaderFont = New Font("宋体", 10, FontStyle.Bold)
        m_ItemFont = New Font("宋体", 9, FontStyle.Regular)
        m_TextFont = New Font("宋体", 9, FontStyle.Regular)

        '笔刷设置
        m_Brush = New SolidBrush(Color.Black)
        m_Pen = New Pen(New SolidBrush(Color.Black))



        '单页高度设置,单位为厘米 英寸
        '_dpiX = 600
        '_dpiY = 600

        '宽度设置:厘米 * 567 = twips / 1440 = 英寸 * _dpiX =像素
        m_VoucherPageWidth = 21.7 / 2.54 * _dpiX '凭证区总体宽度，即不管纸张多少，不超过此宽度
        m_RowWidth = 21.3 / 2.54 * _dpiX '分录区总体宽度
        m_ExpWidth = 6.4 / 2.54 * _dpiX '摘要区宽度
        m_AcctWidth = 6.8 / 2.54 * _dpiX '编码区
        m_CreditWidth = 3.4 / 2.54 * _dpiX '借方
        m_DebitWidth = 3.4 / 2.54 * _dpiX '贷方
        m_VoucherSignWidth = 1.3 / 2.54 * _dpiX '记账符号区

        m_CompanyWidth = 8.76 / 2.54 * _dpiX '核算单位区

        m_VoucherFooterTextWidth = 3.55 / 2.54 * _dpiX '底部信息区宽度（平均 6 个）

        '高度设置
        m_PageTitleHeight = 1.698 / 2.54 * _dpiY '记账凭证标题区高度
        m_PageInfoHeight = 0.605 / 2.54 * _dpiY '凭证主体信息高底（单位名称等)

        m_EntryHeaderHeight = 1.6 / 2.54 * _dpiY '分录标题高度
        m_ItemHeight = 0.81 / 2.54 * _dpiY '分录高度(合计区同此高度)
        m_PageFooterHeight = 0.81 / 2.54 * _dpiY '底部信息区高度（经手人等）

        '宽度设置
    End Sub


#Region "属性区"
    Public Property VoucherList As List(Of ClsTVoucher)
        Get
            Return m_VoucherList
        End Get
        Set(value As List(Of ClsTVoucher))
            m_VoucherList = value

            _TotalVouchers = m_VoucherList.Count

            '重新计算分页
            StatisticsPages()
        End Set
    End Property

    Public Property LeftMargin As Single
        Get
            Return m_LeftMargin
        End Get
        Set(value As Single)
            m_LeftMargin = value
        End Set
    End Property

    Public Property RightMargin As Single
        Get
            Return m_RightMargin
        End Get
        Set(value As Single)
            m_RightMargin = value
        End Set
    End Property

    Public Property TopMargin As Single
        Get
            Return m_TopMargin
        End Get
        Set(value As Single)
            m_TopMargin = value
        End Set
    End Property

    Public Property BottomMargin As Single
        Get
            Return m_BottomMargin
        End Get
        Set(value As Single)
            m_BottomMargin = value
        End Set
    End Property

    Public Property TitleFont As Font
        Get
            Return m_TitleFont
        End Get
        Set(value As Font)
            m_TitleFont = value
        End Set
    End Property

    Public Property HeaderFont As Font
        Get
            Return m_HeaderFont
        End Get
        Set(value As Font)
            m_HeaderFont = value
        End Set
    End Property

    Public Property ItemFont As Font
        Get
            Return m_ItemFont
        End Get
        Set(value As Font)
            m_ItemFont = value
        End Set
    End Property

    Public Property TextFont As Font
        Get
            Return m_TextFont
        End Get
        Set(value As Font)
            m_TextFont = value
        End Set
    End Property

    Public Property Brush As SolidBrush
        Get
            Return m_Brush
        End Get
        Set(value As SolidBrush)
            m_Brush = value
        End Set
    End Property

    Public Property Pen As Pen
        Get
            Return m_Pen
        End Get
        Set(value As Pen)
            m_Pen = value
        End Set
    End Property

    Public Property ItemHeight As Integer
        Get
            Return m_ItemHeight
        End Get
        Set(value As Integer)
            m_ItemHeight = value
        End Set
    End Property

    Public Property PageFooterHeight As Integer
        Get
            Return m_PageFooterHeight
        End Get
        Set(value As Integer)
            m_PageFooterHeight = value
        End Set
    End Property

    Public Property PageTitleHeight As Integer
        Get
            Return m_PageTitleHeight
        End Get
        Set(value As Integer)
            m_PageTitleHeight = value
        End Set
    End Property

    Public Property CompanyName As String
        Get
            Return m_CompanyName
        End Get
        Set(value As String)
            m_CompanyName = value
        End Set
    End Property

    Public Property EndCallBack As EndPrintCallBack
        Get
            Return m_EndCallBack
        End Get
        Set(value As EndPrintCallBack)
            m_EndCallBack = value
        End Set
    End Property

    Public Property VoucherTitle As String
        Get
            Return m_VoucherTitle
        End Get
        Set(value As String)
            m_VoucherTitle = value
        End Set
    End Property

    Public Property EntryHeaderHeight As Integer
        Get
            Return m_EntryHeaderHeight
        End Get
        Set(value As Integer)
            m_EntryHeaderHeight = value
        End Set
    End Property

    Public Property PageInfoHeight As Integer
        Get
            Return m_PageInfoHeight
        End Get
        Set(value As Integer)
            m_PageInfoHeight = value
        End Set
    End Property

    Public Property ExpWidth As Integer
        Get
            Return m_ExpWidth
        End Get
        Set(value As Integer)
            m_ExpWidth = value
        End Set
    End Property

    Public Property AcctWidth As Integer
        Get
            Return m_AcctWidth
        End Get
        Set(value As Integer)
            m_AcctWidth = value
        End Set
    End Property


    Public Property CreditWidth As Integer
        Get
            Return m_CreditWidth
        End Get
        Set(value As Integer)
            m_CreditWidth = value
        End Set
    End Property

    Public Property DebitWidth As Integer
        Get
            Return m_DebitWidth
        End Get
        Set(value As Integer)
            m_DebitWidth = value
        End Set
    End Property

    Public Property CompanyWidth As Integer
        Get
            Return m_CompanyWidth
        End Get
        Set(value As Integer)
            m_CompanyWidth = value
        End Set
    End Property

    Public Property VoucherPageWidth As Integer
        Get
            Return m_VoucherPageWidth
        End Get
        Set(value As Integer)
            m_VoucherPageWidth = value
        End Set
    End Property

    Public Property RowWidth As Integer
        Get
            Return m_RowWidth
        End Get
        Set(value As Integer)
            m_RowWidth = value
        End Set
    End Property

    Public Property VoucherSignWidth As Integer
        Get
            Return m_VoucherSignWidth
        End Get
        Set(value As Integer)
            m_VoucherSignWidth = value
        End Set
    End Property

    Public Property ExpTitle As String
        Get
            Return m_ExpTitle
        End Get
        Set(value As String)
            m_ExpTitle = value
        End Set
    End Property

    Public Property AcctTitle As String
        Get
            Return m_AcctTitle
        End Get
        Set(value As String)
            m_AcctTitle = value
        End Set
    End Property

    Public Property CreditTtile As String
        Get
            Return m_CreditTtile
        End Get
        Set(value As String)
            m_CreditTtile = value
        End Set
    End Property

    Public Property DebitTitle As String
        Get
            Return m_DebitTitle
        End Get
        Set(value As String)
            m_DebitTitle = value
        End Set
    End Property

    Public Property SignTitle As String
        Get
            Return m_SignTitle
        End Get
        Set(value As String)
            m_SignTitle = value
        End Set
    End Property


#End Region

#Region "统计分页"
    Private Sub StatisticsPages()

        If m_VoucherList Is Nothing OrElse m_VoucherList.Count < 1 Then
            Return
        End If

        '总页数暂时等于凭证数
        _TotalPages = m_VoucherList.Count

        '计算凭证总分录数
        Dim tmpRows As Integer = 0
        For Each tmpV As ClsTVoucher In m_VoucherList
            tmpRows += tmpV.EntryList.Count
            '如果分录数大于6，则总页数增加
            If tmpV.EntryList.Count Mod _RowsOfPage = 0 Then
                _TotalPages += (tmpV.EntryList.Count \ _RowsOfPage - 1)
            Else
                _TotalPages += (tmpV.EntryList.Count \ _RowsOfPage)
            End If
        Next

        If tmpRows < 1 Then
            Return
        End If

        _RowsOfAllPages = tmpRows
    End Sub

#End Region

#Region "打印预览"

    Public Function PrintVoucher() As Printing.PrintDocument
        Dim printDoc As Printing.PrintDocument = New Printing.PrintDocument()
        '取出纸张设置
        If My.Settings.VoucherPageSettings IsNot Nothing Then
            printDoc.DefaultPageSettings = My.Settings.VoucherPageSettings
        End If
        '设置总页数
        printDoc.DocumentName = _TotalPages.ToString()

        AddHandler printDoc.PrintPage, AddressOf PrintVoucherPage
        AddHandler printDoc.BeginPrint, AddressOf BeginPrintVoucher
        AddHandler printDoc.EndPrint, AddressOf EndPrintVoucher

        Return printDoc
    End Function

    'Public Function PreviewVoucher() As PrintPreviewDialog
    '    Dim printDoc As Printing.PrintDocument = New Printing.PrintDocument()

    '    'printDoc.PrinterSettings.MaximumPage = _TotalPages
    '    printDoc.DocumentName = _TotalPages.ToString()

    '    AddHandler printDoc.PrintPage, AddressOf PrintVoucherPage
    '    AddHandler printDoc.BeginPrint, AddressOf BeginPrintVoucher
    '    AddHandler printDoc.EndPrint, AddressOf EndPrintVoucher

    '    Dim printPreview As PrintPreviewDialog = New PrintPreviewDialog()
    '    printPreview.Document = printDoc

    '    Return printPreview

    'End Function
#End Region

#Region "打印事件"

    Private Sub PrintVoucherPage(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs)
        'Debug.Print("当前打印单位：" & e.Graphics.PageUnit)
        Debug.Print("当前打印页：" & _CurrentPage)

        '当前页数累加,当前页数从1算起
        _CurrentPage += 1

        '当前是否正在打印多页凭证？
        If Not _IfMultiPageOfVoucher Then
            '否(不是多页凭证或者第一次进入)
            '分录数量
            _RowsOfCurrentVoucher = m_VoucherList(_CurrentVoucherIndex).EntryList.Count
            If _RowsOfCurrentVoucher > 6 Then
                '当前分录数量大于6，则需要分页
                _IfMultiPageOfVoucher = True
                '分页数量
                '计算当前凭证需要几页才能打印完毕
                If _RowsOfCurrentVoucher Mod 6 <> 0 Then
                    _PagesOfCurrentVoucher = _RowsOfCurrentVoucher \ 6 + 1
                Else
                    _PagesOfCurrentVoucher = _RowsOfCurrentVoucher
                End If
                '当前打印页为第一页
                _PrintingPageOfCurrentVoucher = 1
                '当前分录索引为0，即第一页是从分录0开始
                _RowIndexOfCurrentVoucher = 0 '马上要打印的页分录是从此索引处开始。
                _RowsOfPrintingPageOfCurrentVoucher = 6 '马上要打印的页分录是6行
                _LeftRowsOfCurrentVoucher = _RowsOfCurrentVoucher - _RowsOfPrintingPageOfCurrentVoucher '还剩下多少分录？
            Else
                '当前凭证的分录数量不大于6
                _IfMultiPageOfVoucher = False
                _PrintingPageOfCurrentVoucher = 1 '当前页是凭证的第1页
                _RowIndexOfCurrentVoucher = 0 '分录索引从0开始
                _RowsOfPrintingPageOfCurrentVoucher = _RowsOfCurrentVoucher '需要打印的分录数是总分录数
                _PagesOfCurrentVoucher = 1 '当前凭证只有一页
                _LeftRowsOfCurrentVoucher = 0
            End If
        Else
            '是（正在打印多页凭证，且不是第一页）
            _PrintingPageOfCurrentVoucher += 1 '当前打印页数增1
            _RowIndexOfCurrentVoucher += 6 '当前页分录索引加6
            '判断是否为该凭证的最后一页
            If _PrintingPageOfCurrentVoucher = _PagesOfCurrentVoucher Then
                _RowsOfPrintingPageOfCurrentVoucher = _LeftRowsOfCurrentVoucher '当前页分录数为剩余数

                _IfMultiPageOfVoucher = False '表明多页凭证打印结束，即打印完此页后进入下一个凭证。
            Else
                _RowsOfPrintingPageOfCurrentVoucher = 6
                _LeftRowsOfCurrentVoucher -= 6
            End If

        End If

        '当前绘制起始点
        _CurrentPoint = New Point(m_LeftMargin, m_TopMargin)

        '画背景字：记账凭证
        DrawVoucherTitle(e)
        '画主体信息部分：公司、日期、字号、附件数
        DrawVoucherInfo(e)
        '画标题：
        DrawEntryHeader(e)
        '画分录：
        DrawEntryItems(e)
        '画合计：
        DrawVoucherSum(e)
        '画凭证脚：人员信息
        DrawVoucherFooter(e)

        '当前凭证累加
        If Not _IfMultiPageOfVoucher Then
            '如果不是多页凭证，则凭证索引增1
            _CurrentVoucherIndex += 1
            If _CurrentVoucherIndex >= m_VoucherList.Count - 1 Then
                _CurrentVoucherIndex = m_VoucherList.Count - 1
            End If
        End If

        '判断是否是最后一页
        If _CurrentPage >= _TotalPages Then
            '设置打印完毕
            e.HasMorePages = False
            '重置打印当前页
            _CurrentPage = 0
            '重置凭证列表索引
            _CurrentVoucherIndex = 0
        Else
            e.HasMorePages = True
        End If

    End Sub

    Private Sub BeginPrintVoucher(ByVal sender As Object, ByVal e As Printing.PrintEventArgs)
        '
        Debug.Print("开始打印：" & _CurrentPage)
        '重置打印变量
        _CurrentPage = 0

        _CurrentRowOfPage = 0
        _RowsOfAllPages = 0
        _CurrentRowOfAllPages = 0

        '多页凭证变量
        _IfMultiPageOfVoucher = False  '当前打印凭证是否为多页
        _RowsOfCurrentVoucher = -1 '当前打印凭证总共有几行分录
        _PagesOfCurrentVoucher = 1 '当前打印凭证需要几页
        _PrintingPageOfCurrentVoucher = 1 '当前正在打印的是当前凭证的第几页
        _RowIndexOfCurrentVoucher = -1 '当前打印凭证的下一页的行数索引（如果是第一页，则是6）
        _LeftRowsOfCurrentVoucher = 0 '当前打印凭证的下一页还有几行分录(如果是第一页，则是 分录总数 - 6)

        '打印不能取消
        e.Cancel = False
    End Sub

    Private Sub EndPrintVoucher(ByVal sender As Object, ByVal e As Printing.PrintEventArgs)

        If m_EndCallBack IsNot Nothing Then
            Dim ec As PrintCallBackEventArgs = New PrintCallBackEventArgs()
            ec.Msg = "打印完毕。"
            ec.PrintStatus = True

            m_EndCallBack.Invoke(Me, ec)

        End If
    End Sub

#End Region

#Region "绘制文档部分"

    ''' <summary>
    ''' 输出凭证底部信息
    ''' </summary>
    ''' <param name="e"></param>
    Private Sub DrawVoucherFooter(ByVal e As Printing.PrintPageEventArgs)
        '会计主管：
        Dim managerRect As Rectangle = New Rectangle()
        managerRect.X = _CurrentPoint.X
        managerRect.Y = _CurrentPoint.Y
        managerRect.Width = m_VoucherFooterTextWidth
        managerRect.Height = m_PageFooterHeight
        DrawCellValue(e, m_TextFont, m_Brush, "主管：", managerRect, ContentAlignment.MiddleLeft)

        '记账
        Dim posterRect As Rectangle = New Rectangle()
        posterRect.X = _CurrentPoint.X + m_VoucherFooterTextWidth
        posterRect.Y = _CurrentPoint.Y
        posterRect.Width = m_VoucherFooterTextWidth
        posterRect.Height = m_PageFooterHeight
        DrawCellValue(e, m_TextFont, m_Brush, "记账：" & m_VoucherList(_CurrentVoucherIndex).Poster, posterRect, ContentAlignment.MiddleLeft)

        '审核
        Dim checkerRect As Rectangle = New Rectangle()
        checkerRect.X = _CurrentPoint.X + m_VoucherFooterTextWidth * 2
        checkerRect.Y = _CurrentPoint.Y
        checkerRect.Width = m_VoucherFooterTextWidth
        checkerRect.Height = m_PageFooterHeight
        DrawCellValue(e, m_TextFont, m_Brush, "审核：" & m_VoucherList(_CurrentVoucherIndex).Checker, checkerRect, ContentAlignment.MiddleLeft)

        '出纳
        Dim casherRect As Rectangle = New Rectangle()
        casherRect.X = _CurrentPoint.X + m_VoucherFooterTextWidth * 3
        casherRect.Y = _CurrentPoint.Y
        casherRect.Width = m_VoucherFooterTextWidth
        casherRect.Height = m_PageFooterHeight
        DrawCellValue(e, m_TextFont, m_Brush, "出纳：" & m_VoucherList(_CurrentVoucherIndex).Casher, casherRect, ContentAlignment.MiddleLeft)

        '制单
        Dim makerRect As Rectangle = New Rectangle()
        makerRect.X = _CurrentPoint.X + m_VoucherFooterTextWidth * 4
        makerRect.Y = _CurrentPoint.Y
        makerRect.Width = m_VoucherFooterTextWidth
        makerRect.Height = m_PageFooterHeight
        DrawCellValue(e, m_TextFont, m_Brush, "制单：" & m_VoucherList(_CurrentVoucherIndex).Maker, makerRect, ContentAlignment.MiddleLeft)

        '经手
        Dim handerRect As Rectangle = New Rectangle()
        handerRect.X = _CurrentPoint.X + m_VoucherFooterTextWidth * 5
        handerRect.Y = _CurrentPoint.Y
        handerRect.Width = m_VoucherFooterTextWidth
        handerRect.Height = m_PageFooterHeight
        DrawCellValue(e, m_TextFont, m_Brush, "经手：" & m_VoucherList(_CurrentVoucherIndex).Hander, handerRect, ContentAlignment.MiddleLeft)

    End Sub

    ''' <summary>
    ''' 输出分录的文字部分
    ''' </summary>
    ''' <param name="e"></param>
    Private Sub DrawEntryValue(ByVal e As Printing.PrintPageEventArgs, ByVal entry As ClsTVoucherDetail)
        '输出 摘要文字
        Dim expRect As Rectangle = New Rectangle()
        expRect.X = _CurrentPoint.X
        expRect.Y = _CurrentPoint.Y
        expRect.Width = ExpWidth
        expRect.Height = m_ItemHeight '* e.Graphics.DpiY
        DrawCellValue(e, m_ItemFont, m_Brush, entry.Excerpta, expRect, ContentAlignment.MiddleLeft)

        '输出会计科目文字
        Dim acctRect As Rectangle = New Rectangle()
        acctRect.X = _CurrentPoint.X + m_ExpWidth
        acctRect.Y = _CurrentPoint.Y
        acctRect.Width = m_AcctWidth
        acctRect.Height = m_ItemHeight
        DrawCellValue(e, m_ItemFont, m_Brush, entry.AccountCodeName & "[" & entry.AccountCode & "]", acctRect, ContentAlignment.MiddleLeft)


        '输出借方文字
        Dim creditRect As Rectangle = New Rectangle()
        creditRect.X = acctRect.X + m_AcctWidth
        creditRect.Y = _CurrentPoint.Y
        creditRect.Width = m_CreditWidth
        creditRect.Height = m_ItemHeight
        DrawCellValue(e, m_ItemFont, m_Brush, entry.Credit.ToString("#,#.00"), creditRect, ContentAlignment.MiddleRight)

        '输出贷方文字
        Dim debitRect As Rectangle = New Rectangle()
        debitRect.X = creditRect.X + m_CreditWidth
        debitRect.Y = _CurrentPoint.Y
        debitRect.Width = m_DebitWidth
        debitRect.Height = m_ItemHeight
        DrawCellValue(e, m_ItemFont, m_Brush, entry.Debit.ToString("#,#.00"), debitRect, ContentAlignment.MiddleRight)

    End Sub

    ''' <summary>
    ''' 输出凭证合计表格
    ''' </summary>
    ''' <param name="e"></param>
    Private Sub DrawVoucherSum(ByVal e As Printing.PrintPageEventArgs)
        '画表格线
        '_CurrentPoint 坐标不变
        '画顶部线
        Dim rightTopPoint As Point = New Point()
        rightTopPoint.X = _CurrentPoint.X + m_RowWidth
        rightTopPoint.Y = _CurrentPoint.Y
        e.Graphics.DrawLine(m_Pen, _CurrentPoint, rightTopPoint)

        '画左侧线
        Dim leftBottomPoint As Point = New Point()
        leftBottomPoint.X = _CurrentPoint.X
        leftBottomPoint.Y = _CurrentPoint.Y + ItemHeight
        e.Graphics.DrawLine(m_Pen, _CurrentPoint, leftBottomPoint)

        '画右侧线
        Dim rightBottomPoint As Point = New Point()
        rightBottomPoint.X = rightTopPoint.X
        rightBottomPoint.Y = leftBottomPoint.Y
        e.Graphics.DrawLine(m_Pen, rightTopPoint, rightBottomPoint)


        '画科目右侧线
        Dim acctRightTopPoint As Point = New Point()
        acctRightTopPoint.X = _CurrentPoint.X + m_ExpWidth + m_AcctWidth
        acctRightTopPoint.Y = _CurrentPoint.Y
        Dim acctRightBottomPoint As Point = New Point()
        acctRightBottomPoint.X = acctRightTopPoint.X
        acctRightBottomPoint.Y = acctRightTopPoint.Y + ItemHeight
        e.Graphics.DrawLine(m_Pen, acctRightTopPoint, acctRightBottomPoint)

        '画借方右侧线
        Dim creditRightTopPoint As Point = New Point()
        creditRightTopPoint.X = acctRightTopPoint.X + m_CreditWidth
        creditRightTopPoint.Y = _CurrentPoint.Y
        Dim creditRightBottomPoint As Point = New Point()
        creditRightBottomPoint.X = creditRightTopPoint.X
        creditRightBottomPoint.Y = creditRightTopPoint.Y + ItemHeight
        e.Graphics.DrawLine(m_Pen, creditRightTopPoint, creditRightBottomPoint)

        '画贷方右侧线
        Dim debitRightTopPoint As Point = New Point()
        debitRightTopPoint.X = creditRightTopPoint.X + m_DebitWidth
        debitRightTopPoint.Y = _CurrentPoint.Y
        Dim debitRightBottomPoint As Point = New Point()
        debitRightBottomPoint.X = debitRightTopPoint.X
        debitRightBottomPoint.Y = _CurrentPoint.Y + ItemHeight
        e.Graphics.DrawLine(m_Pen, debitRightTopPoint, debitRightBottomPoint)

        '画下方表格线
        Dim bottomTopPoint As Point = New Point()
        bottomTopPoint.X = _CurrentPoint.X ' + m_RowWidth
        bottomTopPoint.Y = _CurrentPoint.Y + m_ItemHeight
        Dim bottomBottomPoint As Point = New Point()
        bottomBottomPoint.X = _CurrentPoint.X + m_RowWidth
        bottomBottomPoint.Y = _CurrentPoint.Y + m_ItemHeight
        e.Graphics.DrawLine(m_Pen, bottomTopPoint, bottomBottomPoint)

        '输出大写
        Dim moneyRect As Rectangle = New Rectangle()
        moneyRect.X = _CurrentPoint.X
        moneyRect.Y = _CurrentPoint.Y
        moneyRect.Width = m_ExpWidth + m_AcctWidth
        moneyRect.Height = m_ItemHeight
        DrawCellValue(e, m_HeaderFont, m_Brush, "金额大写：" & m_VoucherList(_CurrentVoucherIndex).MoneyHz, moneyRect, ContentAlignment.MiddleLeft)

        '输出借方合计
        Dim creditRect As Rectangle = New Rectangle()
        creditRect.X = _CurrentPoint.X + m_ExpWidth + m_AcctWidth
        creditRect.Y = _CurrentPoint.Y
        creditRect.Width = m_CreditWidth
        creditRect.Height = m_ItemHeight
        DrawCellValue(e, m_HeaderFont, m_Brush, m_VoucherList(_CurrentVoucherIndex).SumOfCredit.ToString("#,#.00"), creditRect, ContentAlignment.MiddleRight)

        '输出贷方合计
        Dim debitRect As Rectangle = New Rectangle()
        debitRect.X = creditRect.X + m_CreditWidth
        debitRect.Y = _CurrentPoint.Y
        debitRect.Width = m_DebitWidth
        debitRect.Height = m_ItemHeight
        DrawCellValue(e, m_HeaderFont, m_Brush, m_VoucherList(_CurrentVoucherIndex).SumOfDebit.ToString("#,#.00"), debitRect, ContentAlignment.MiddleRight)

        '坐标移动
        _CurrentPoint.X = m_LeftMargin
        _CurrentPoint.Y += m_ItemHeight
    End Sub

    ''' <summary>
    ''' 画分录部分
    ''' </summary>
    ''' <param name="e"></param>
    Private Sub DrawEntryItems(ByVal e As Printing.PrintPageEventArgs)
        '取出当前凭证的分录索引
        Dim rowIndex As Integer = _RowIndexOfCurrentVoucher
        '取出当前打印页的分录数量
        Dim entryiesInRow As Integer = _RowsOfPrintingPageOfCurrentVoucher
        '判断需要补充几个空行
        Dim blankRows As Integer = _RowsOfPage - entryiesInRow '如果是0，则说明不用补空行

        '输出分录内容
        For i As Integer = 0 To entryiesInRow - 1
            '画分录表格线
            DrawItemLine(e, m_ItemHeight)
            '输出分录文字部分
            DrawEntryValue(e, m_VoucherList(_CurrentVoucherIndex).EntryList(rowIndex))
            rowIndex += 1
            '坐标移动
            _CurrentPoint.X = m_LeftMargin
            _CurrentPoint.Y += m_ItemHeight
        Next

        '补空行
        For j As Integer = 1 To blankRows
            '画分录表格线
            DrawItemLine(e, m_ItemHeight)
            '坐标移动
            _CurrentPoint.X = m_LeftMargin
            _CurrentPoint.Y += m_ItemHeight
        Next

    End Sub

    ''' <summary>
    ''' 绘制单元格内容
    ''' </summary>
    ''' <param name="e">打印页面参数</param>
    ''' <param name="v">打印的字串值</param>
    ''' <param name="rect">字串打印的矩形</param>
    ''' <param name="align">字串的对齐方式</param>
    Private Sub DrawCellValue(ByVal e As Printing.PrintPageEventArgs, ByVal font As Font, ByVal brush As Brush, ByVal v As String, ByVal rect As Rectangle, ByVal align As ContentAlignment)
        '求字串宽高
        Dim strSizeF As SizeF = e.Graphics.MeasureString(v, font)
        '计算需要几行？
        Dim needLines As Integer = 1
        ' = IIf(rect.Width Mod strSizeF.Width = 0, rect.Width \ strSizeF.Width, rect.Width \ strSizeF.Width + 1)
        If strSizeF.Width > rect.Width Then
            '计算行数
            needLines = IIf(strSizeF.Width Mod rect.Width = 0, strSizeF.Width \ rect.Width, strSizeF.Width \ rect.Width + 1)
        End If
        '计算可容纳行数
        Dim allowLinews As Integer = rect.Height \ strSizeF.Height
        '判断可打印行数
        Dim lines As Integer = IIf(needLines > allowLinews, allowLinews, needLines)
        '打印数组
        Dim strs(lines - 1) As String

        Dim charIndex As Integer = 0
        For i As Integer = 0 To lines - 1
            strs(i) = ""
            For j As Integer = charIndex To v.Length - 1
                strs(i) &= v.Substring(j, 1)
                '判断长度是否达到了宽度值
                If e.Graphics.MeasureString(strs(i), font).Width > rect.Width Then
                    '退回一个字符
                    strs(i) = v.Substring(charIndex, strs(i).Length - 1)

                    charIndex = j

                    Exit For
                End If
            Next
        Next
        '开始打印输出
        Dim startX As Integer = rect.X
        Dim startY As Integer = rect.Y + (rect.Height - strSizeF.Height * lines) / 2 '第一行起始点,即纵向居中
        Dim outX As Single  '每行输出的X点
        Dim outY As Single  '每行输出的Y点

        For z As Integer = 0 To lines - 1
            'X计算要看对齐方式
            Select Case align
                Case ContentAlignment.MiddleCenter
                    outX = startX + rect.Width / 2 - e.Graphics.MeasureString(strs(z), font).Width / 2
                Case ContentAlignment.MiddleLeft
                    outX = startX
                Case ContentAlignment.MiddleRight
                    outX = startX + rect.Width - e.Graphics.MeasureString(strs(z), font).Width
                Case Else
                    outX = startX
            End Select

            outY = startY + z * strSizeF.Height
            e.Graphics.DrawString(strs(z), font, brush, outX, outY)
        Next

    End Sub

    ''' <summary>
    ''' 画表格线
    ''' </summary>
    ''' <param name="e"></param>
    ''' <param name="itemHeight"></param>
    Private Sub DrawItemLine(ByVal e As Printing.PrintPageEventArgs, ByVal itemHeight As Integer)
        '_CurrentPoint 坐标不变
        '画顶部线
        Dim rightTopPoint As Point = New Point()
        rightTopPoint.X = _CurrentPoint.X + m_RowWidth
        rightTopPoint.Y = _CurrentPoint.Y
        e.Graphics.DrawLine(m_Pen, _CurrentPoint, rightTopPoint)

        '画左侧线
        Dim leftBottomPoint As Point = New Point()
        leftBottomPoint.X = _CurrentPoint.X
        leftBottomPoint.Y = _CurrentPoint.Y + itemHeight
        e.Graphics.DrawLine(m_Pen, _CurrentPoint, leftBottomPoint)

        '画右侧线
        Dim rightBottomPoint As Point = New Point()
        rightBottomPoint.X = rightTopPoint.X
        rightBottomPoint.Y = leftBottomPoint.Y
        e.Graphics.DrawLine(m_Pen, rightTopPoint, rightBottomPoint)

        '画摘要右侧线
        Dim expRightTopPoint As Point = New Point()
        expRightTopPoint.X = _CurrentPoint.X + m_ExpWidth
        expRightTopPoint.Y = _CurrentPoint.Y
        Dim expRightBottomPoint As Point = New Point()
        expRightBottomPoint.X = expRightTopPoint.X
        expRightBottomPoint.Y = expRightTopPoint.Y + itemHeight
        e.Graphics.DrawLine(m_Pen, expRightTopPoint, expRightBottomPoint)

        '画科目右侧线
        Dim acctRightTopPoint As Point = New Point()
        acctRightTopPoint.X = expRightTopPoint.X + m_AcctWidth
        acctRightTopPoint.Y = _CurrentPoint.Y
        Dim acctRightBottomPoint As Point = New Point()
        acctRightBottomPoint.X = acctRightTopPoint.X
        acctRightBottomPoint.Y = acctRightTopPoint.Y + itemHeight
        e.Graphics.DrawLine(m_Pen, acctRightTopPoint, acctRightBottomPoint)

        '画借方右侧线
        Dim creditRightTopPoint As Point = New Point()
        creditRightTopPoint.X = acctRightTopPoint.X + m_CreditWidth
        creditRightTopPoint.Y = _CurrentPoint.Y
        Dim creditRightBottomPoint As Point = New Point()
        creditRightBottomPoint.X = creditRightTopPoint.X
        creditRightBottomPoint.Y = creditRightTopPoint.Y + itemHeight
        e.Graphics.DrawLine(m_Pen, creditRightTopPoint, creditRightBottomPoint)

        '画贷方右侧线
        Dim debitRightTopPoint As Point = New Point()
        debitRightTopPoint.X = creditRightTopPoint.X + m_DebitWidth
        debitRightTopPoint.Y = _CurrentPoint.Y
        Dim debitRightBottomPoint As Point = New Point()
        debitRightBottomPoint.X = debitRightTopPoint.X
        debitRightBottomPoint.Y = _CurrentPoint.Y + itemHeight
        e.Graphics.DrawLine(m_Pen, debitRightTopPoint, debitRightBottomPoint)

    End Sub

    ''' <summary>
    ''' 打印输出 分录标题
    ''' </summary>
    ''' <param name="e"></param>
    Private Sub DrawEntryHeader(ByVal e As Printing.PrintPageEventArgs)
        ''画顶部线
        'Dim rightTopPoint As Point = New Point()
        'rightTopPoint.X = _CurrentPoint.X + m_RowWidth
        'rightTopPoint.Y = _CurrentPoint.Y
        'e.Graphics.DrawLine(m_Pen, _CurrentPoint, rightTopPoint)

        ''画左侧线
        'Dim leftBottomPoint As Point = New Point()
        'leftBottomPoint.X = _CurrentPoint.X
        'leftBottomPoint.Y = _CurrentPoint.Y + m_EntryHeaderHeight
        'e.Graphics.DrawLine(m_Pen, _CurrentPoint, leftBottomPoint)

        ''画右侧线
        'Dim rightBottomPoint As Point = New Point()
        'rightBottomPoint.X = rightTopPoint.X
        'rightBottomPoint.Y = leftBottomPoint.Y
        'e.Graphics.DrawLine(m_Pen, rightTopPoint, rightBottomPoint)

        ''画摘要右侧线
        'Dim expRightTopPoint As Point = New Point()
        'expRightTopPoint.X = _CurrentPoint.X + m_ExpWidth
        'expRightTopPoint.Y = _CurrentPoint.Y
        'Dim expRightBottomPoint As Point = New Point()
        'expRightBottomPoint.X = expRightTopPoint.X
        'expRightBottomPoint.Y = expRightTopPoint.Y + m_EntryHeaderHeight
        'e.Graphics.DrawLine(m_Pen, expRightTopPoint, expRightBottomPoint)

        ''画科目右侧线
        'Dim acctRightTopPoint As Point = New Point()
        'acctRightTopPoint.X = expRightTopPoint.X + m_AcctWidth
        'acctRightTopPoint.Y = _CurrentPoint.Y
        'Dim acctRightBottomPoint As Point = New Point()
        'acctRightBottomPoint.X = acctRightTopPoint.X
        'acctRightBottomPoint.Y = acctRightTopPoint.Y + m_EntryHeaderHeight
        'e.Graphics.DrawLine(m_Pen, acctRightTopPoint, acctRightBottomPoint)

        ''画借方右侧线
        'Dim creditRightTopPoint As Point = New Point()
        'creditRightTopPoint.X = acctRightTopPoint.X + m_CreditWidth
        'creditRightTopPoint.Y = _CurrentPoint.Y
        'Dim creditRightBottomPoint As Point = New Point()
        'creditRightBottomPoint.X = creditRightTopPoint.X
        'creditRightBottomPoint.Y = creditRightTopPoint.Y + m_EntryHeaderHeight
        'e.Graphics.DrawLine(m_Pen, creditRightTopPoint, creditRightBottomPoint)

        ''画贷方右侧线
        'Dim debitRightTopPoint As Point = New Point()
        'debitRightTopPoint.X = creditRightTopPoint.X + m_DebitWidth
        'debitRightTopPoint.Y = _CurrentPoint.Y
        'Dim debitRightBottomPoint As Point = New Point()
        'debitRightBottomPoint.X = debitRightTopPoint.X
        'debitRightBottomPoint.Y = _CurrentPoint.Y + m_EntryHeaderHeight
        'e.Graphics.DrawLine(m_Pen, debitRightTopPoint, debitRightBottomPoint)

        '输出 摘要文字
        'Dim expXY As SizeF = e.Graphics.MeasureString(m_ExpTitle, m_HeaderFont)
        'Dim expX As Single = _CurrentPoint.X + (m_ExpWidth / 2 - expXY.Width / 2)
        'Dim expY As Single = _CurrentPoint.Y + (m_EntryHeaderHeight / 2 - expXY.Height / 2)
        'e.Graphics.DrawString(m_ExpTitle, m_HeaderFont, m_Brush, expX, expY)

        '输出会计科目文字
        'Dim acctXY As SizeF = e.Graphics.MeasureString(m_AcctTitle, m_HeaderFont)
        'Dim acctX As Single = _CurrentPoint.X + m_ExpWidth + (m_AcctWidth / 2 - acctXY.Width / 2)
        'Dim acctY As Single = expY
        'e.Graphics.DrawString(m_AcctTitle, m_HeaderFont, m_Brush, acctX, acctY)

        '输出借方文字
        'Dim creditXY As SizeF = e.Graphics.MeasureString(m_CreditTtile, m_HeaderFont)
        'Dim creditX As Single = _CurrentPoint.X + m_ExpWidth + m_AcctWidth + (m_CreditWidth / 2 - creditXY.Width / 2)
        'Dim creditY As Single = expY
        'e.Graphics.DrawString(m_CreditTtile, m_HeaderFont, m_Brush, creditX, creditY)

        '输出贷方文字
        'Dim debitXY As SizeF = e.Graphics.MeasureString(m_DebitTitle, m_HeaderFont)
        'Dim debitX As Single = _CurrentPoint.X + m_ExpWidth + m_AcctWidth + m_CreditWidth + (m_DebitWidth / 2 - debitXY.Width / 2)
        'Dim debitY As Single = expY
        'e.Graphics.DrawString(m_DebitTitle, m_HeaderFont, m_Brush, debitX, debitY)

        '输出凭证符号，需要折行
        'Dim signXY As SizeF = e.Graphics.MeasureString(m_SignTitle, m_HeaderFont)
        'Dim signX As Single = _CurrentPoint.X + m_ExpWidth + m_AcctWidth + m_CreditWidth + m_DebitWidth
        'Dim signY As Single = expY
        'e.Graphics.DrawString(m_SignTitle, m_HeaderFont, m_Brush, signX, signY)

        '画表格表头线
        DrawItemLine(e, m_EntryHeaderHeight)

        '输出 摘要文字
        Dim expRect As Rectangle = New Rectangle()
        expRect.X = _CurrentPoint.X
        expRect.Y = _CurrentPoint.Y
        expRect.Width = ExpWidth
        expRect.Height = m_EntryHeaderHeight
        DrawCellValue(e, m_HeaderFont, m_Brush, m_ExpTitle, expRect, ContentAlignment.MiddleCenter)

        '输出会计科目文字
        Dim acctRect As Rectangle = New Rectangle()
        acctRect.X = _CurrentPoint.X + m_ExpWidth
        acctRect.Y = _CurrentPoint.Y
        acctRect.Width = m_AcctWidth
        acctRect.Height = m_EntryHeaderHeight
        DrawCellValue(e, m_HeaderFont, m_Brush, m_AcctTitle, acctRect, ContentAlignment.MiddleCenter)


        '输出借方文字
        Dim creditRect As Rectangle = New Rectangle()
        creditRect.X = acctRect.X + m_AcctWidth
        creditRect.Y = _CurrentPoint.Y
        creditRect.Width = m_CreditWidth
        creditRect.Height = m_EntryHeaderHeight
        DrawCellValue(e, m_HeaderFont, m_Brush, m_CreditTtile, creditRect, ContentAlignment.MiddleCenter)

        '输出贷方文字
        Dim debitRect As Rectangle = New Rectangle()
        debitRect.X = creditRect.X + m_CreditWidth
        debitRect.Y = _CurrentPoint.Y
        debitRect.Width = m_DebitWidth
        debitRect.Height = m_EntryHeaderHeight
        DrawCellValue(e, m_HeaderFont, m_Brush, m_DebitTitle, debitRect, ContentAlignment.MiddleCenter)

        '输出凭证符号，需要折行
        Dim signRect As Rectangle = New Rectangle()
        signRect.X = debitRect.X + m_DebitWidth
        signRect.Y = _CurrentPoint.Y
        signRect.Width = m_RowWidth - signRect.X
        signRect.Height = m_EntryHeaderHeight
        DrawCellValue(e, m_HeaderFont, m_Brush, m_SignTitle, signRect, ContentAlignment.MiddleCenter)

        '打印光标下移
        _CurrentPoint.X = m_LeftMargin
        _CurrentPoint.Y += m_EntryHeaderHeight

    End Sub

    ''' <summary>
    ''' 打印输出 记账凭证 头部
    ''' </summary>
    ''' <param name="e"></param>
    Private Sub DrawVoucherTitle(ByVal e As Printing.PrintPageEventArgs)

        'Debug.Print("当前的分辨率：dpix=" & e.Graphics.DpiX & " dpiy=" & e.Graphics.DpiY)

        '局部变量
        Dim titleWidth As Integer = e.Graphics.MeasureString(m_VoucherTitle, m_TitleFont).Width
        Dim titleHeight As Integer = e.Graphics.MeasureString(m_VoucherTitle, m_TitleFont).Height
        '绘制凭证头部区
        Dim startX As Integer = e.PageBounds.Width / 2 - titleWidth / 2
        If e.PageBounds.Width > m_VoucherPageWidth Then
            startX = m_VoucherPageWidth / 2 - titleWidth / 2
        End If
        '_CurrentPoint.X = e.PageBounds.Width / 2 - titleWidth / 2
        e.Graphics.DrawString(m_VoucherTitle, m_TitleFont, m_Brush, startX, _CurrentPoint.Y)
        '当前打印开始点下移
        _CurrentPoint.Y += titleHeight
        '标题下画线
        '标题长度
        Dim lineLen As Integer = titleWidth + 50
        Dim lineX As Integer = e.PageBounds.Width / 2 - lineLen / 2
        If e.PageBounds.Width > m_VoucherPageWidth Then
            lineX = m_VoucherPageWidth / 2 - lineLen / 2
        End If
        e.Graphics.DrawLine(m_Pen, New Point(lineX, _CurrentPoint.Y), New Point(lineX + lineLen, _CurrentPoint.Y))
        '向下移动3个单位
        _CurrentPoint.Y += 3
        e.Graphics.DrawLine(m_Pen, New Point(lineX, _CurrentPoint.Y), New Point(lineX + lineLen, _CurrentPoint.Y))

        '向下移动，满足50个高
        _CurrentPoint.Y += (m_PageTitleHeight - titleHeight - 3)
        _CurrentPoint.X = m_LeftMargin

    End Sub

    ''' <summary>
    ''' 打印输出凭证的主体信息：公司 字号 日期 附件数
    ''' </summary>
    ''' <param name="e"></param>
    Private Sub DrawVoucherInfo(ByVal e As Printing.PrintPageEventArgs)
        Dim tmpStr As String = "核算单位：" & m_CompanyName
        Dim tmpSubStr As String = tmpStr
        Dim tmpNameWidth As Integer = e.Graphics.MeasureString(tmpStr, m_TextFont).Width
        '单位信息在最左侧
        If tmpNameWidth > m_CompanyWidth Then

            For i As Integer = 0 To tmpStr.Length
                tmpSubStr = tmpStr.Substring(0, i)
                If e.Graphics.MeasureString(tmpSubStr, m_TextFont).Width > m_CompanyWidth Then
                    '此时截断
                    tmpSubStr = tmpStr.Substring(0, i - 1)
                    '
                    Exit For
                End If
            Next
        End If
        e.Graphics.DrawString(tmpSubStr, m_TextFont, m_Brush, _CurrentPoint)


        '日期信息居中显示 
        Dim tmpDateStr As String = m_VoucherList(_CurrentVoucherIndex).VoucherDate.ToShortDateString()
        Dim tmpDateWidth As Integer = e.Graphics.MeasureString(tmpDateStr, m_TextFont).Width
        Dim x As Integer = m_VoucherPageWidth / 2 - tmpDateWidth / 2

        e.Graphics.DrawString(tmpDateStr, m_TextFont, m_Brush, x, _CurrentPoint.Y)

        '凭证字号对齐右侧
        Dim tmpGroupStr As String = m_VoucherList(_CurrentVoucherIndex).VoucherGroup & "字第" & m_VoucherList(_CurrentVoucherIndex).VoucherNumber & "号"
        Dim tmpGroupWidth As Integer = e.Graphics.MeasureString(tmpGroupStr, m_TextFont).Width
        Dim xg As Integer = m_VoucherPageWidth - tmpGroupWidth

        e.Graphics.DrawString(tmpGroupStr, m_TextFont, m_Brush, xg, _CurrentPoint.Y)

        _CurrentPoint.X = m_LeftMargin 'X 复位
        _CurrentPoint.Y += m_PageInfoHeight 'Y 下移
    End Sub

#End Region
End Class

'Public Class PrintCallBackEventArgs
'    Inherits EventArgs

'    Private m_PrintStatus As Boolean
'    Private m_Msg As String

'    Public Property PrintStatus As Boolean
'        Get
'            Return m_PrintStatus
'        End Get
'        Set(value As Boolean)
'            m_PrintStatus = value
'        End Set
'    End Property

'    Public Property Msg As String
'        Get
'            Return m_Msg
'        End Get
'        Set(value As String)
'            m_Msg = value
'        End Set
'    End Property
'End Class